package shiro.realm;

import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.util.ByteSource;

/**
 * Created by zc on 2016/7/14.
 */
public class MyRealm3 extends AuthorizingRealm {
    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
        return null;
    }

    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
        String userName = "liu";
        String salt2 = "b68b7f8b0d6e598f585b786cfa01c4cc";
        String password = "8f95dd7b94fa8247c81467dd94201e69";
        SimpleAuthenticationInfo simpleAuthenticationInfo =
                new SimpleAuthenticationInfo(userName, password, getName());
        simpleAuthenticationInfo.setCredentialsSalt(ByteSource.Util.bytes(userName + salt2));

        return simpleAuthenticationInfo;
    }
}
